package com.csd.action.teacher;


import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.csd.helper.ActionResult;
import com.csd.helper.IConstant;
import com.csd.serviceImpl.EvaluateItemService;
import com.csd.vo.UserVO;

/**
 * 
 * 教师对项目评审的Action类
 * 
 * @author 尹华彬
 * @version 1.0
 * 
 * <br>
 *          修订时间：2009-12-17 <br>
 *          修改原因：创建文件 <br>
 *          修改人：尹华彬
 * 
 * <br>
 * 
 */
public class TeacherEvaluateAction {

	private Integer evaluateItemID;

	private int score;
	// 老师的评论
	private String comment;
	// 老师的评论
	private String evaluation;

	private EvaluateItemService evaluateItemService;

	

	public Integer getEvaluateItemID() {
		return evaluateItemID;
	}

	public void setEvaluateItemID(Integer evaluateItemID) {
		this.evaluateItemID = evaluateItemID;
	}

	public EvaluateItemService getEvaluateItemService() {
		return evaluateItemService;
	}

	public void setEvaluateItemService(EvaluateItemService evaluateItemService) {
		this.evaluateItemService = evaluateItemService;
	}



	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public String getEvaluation() {
		return evaluation;
	}

	public void setEvaluation(String evaluation) {
		this.evaluation = evaluation;
	}

	

	

	public int getScore() {
		return score;
	}

	public void setScore(int score) {
		this.score = score;
	}

	public String execute() {
		
		String result = ActionResult.fail;
		
		Integer teacherID = null;
		//通过session获得登陆用户ID
		try {
			HttpSession httpSession = ServletActionContext.getRequest().getSession();
			UserVO value = (UserVO)httpSession.getAttribute(IConstant.userVO);
			if(value == null){
				throw  new Exception("用户未登录异常");
			}
			teacherID = value.getUserID();
		} catch (Exception e) {
			e.printStackTrace();
			return result;
		}
		
		if(teacherID == null)
			return result;
		//更新评审项
		evaluateItemService.updateEvaluateItem(evaluateItemID, comment, evaluation, score);
		result = ActionResult.success;
		
		return result;
	}

}
